﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Masters/Basic.Master" AutoEventWireup="true" CodeBehind="AuthorMyList.aspx.cs" Inherits="PMS.UI.BD.AuthorMyList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        $(function () {
            var height = $("#divTotal").height();
            var content = parseFloat(height) - 30;
            $("#tbList").css("height", content);

        });
    </script>
    <script type="text/javascript">

        $(function () {

            $("#divAddAuthor").dialog({
                title: '添加授权',
                width: 280,
                height: 180,
                closed: true,
                cache: false,
                toolbar: "#divToolBar",
            });

        })

        $(function () {
            $("#tbList").datagrid({
                url: '/Logic/BD/UserAjax.aspx?method=GetPerAuthorList',
                loadMsg: '数据加载中请稍后……',
                pagination: true,
                rownumbers: true,
                idField: "ID",
                fitColumns: true,
                columns: [[{
                    //   FromUserId, FromUserName, FromAccountLogIn, ToPassWord, ToUserName, ToUserId, StartTime, EndTime, FillDate, ToAccountLoginIn
                    field: 'ck', checkbox: true, width: 30
                },
                    {
                        field: 'FromUserName', title: '授权人', width: 100, align: "center"
                    },
                    {
                        field: 'ToUserName', title: '被授权人', sortable: true, width: 100, align: "center"
                    }
                    ,
                    {
                        field: 'StartTime', title: '开始时间', sortable: true, width: 150, align: "center"
                    }
                        ,
                    {
                        field: 'EndTime', title: '结束时间', sortable: true, width: 150, align: "center"
                    },
                    {
                        field: 'FillDate', title: '添加时间', sortable: true, width: 150, align: "center"
                    }
                    ,
                    {
                        field: 'ID', title: '状态', sortable: true, width: 120, align: "center", formatter: function (value, row, Index) {
                            var myDate = new Date();
                            var formatDate = utils.formatDate(myDate, "yyyy-MM-dd HH:mm:ss");
                            if (formatDate > row.EndTime) {

                                return "<font color='red'>已结束</font>";
                            }
                            else if (row.StartTime < formatDate && row.EndTime > formatDate) {
                                return "<font color='green'>进行中</font>";
                            } else if (row.StartTime > formatDate) {
                                return "<font color='orange'>未开始</font>";
                            }
                        }
                    }

                ]],
                singleSelect: true,
                pageSize: 20,
                pageList: [ 20, 50, 100],
                striped: true

            });
        })


    </script>
    <script>
        function funcAdd() {
            var myDate = new Date();
            var formatDate = utils.formatDate(myDate, "yyyy-MM-dd HH:mm:ss");
            $("#StartTime").datetimebox("setValue", formatDate);
            $("#divAddAuthor").dialog("open");

        }


        function Confirm() {
            if ($("#authForm").form("validate")) {
                //   alert("aa");
                com.ajax({
                    url: "/Logic/BD/UserAjax.aspx?method=AddAutherInfo",
                    data: com.serializeObj("authForm"),
                    success: function (data) {
                        com.message(data.state, data.msg);
                        $("#divAddAuthor").dialog("close");
                        $("#tbList").datagrid("load");
                    }
                });
            }

        }

        function Cancel() {
            $("#divAddAuthor").dialog("close");
        }

        function funcCancel() {
            var row = $('#tbList').datagrid('getSelected');


            if (row) {
                if (row.FromUserId == "<%=userId%>") {
                    com.ajax({
                        url: "/Logic/BD/UserAjax.aspx?method=FinishAuthor&Id=" + row.ID,
                        success: function (data) {
                            com.message(data.state, data.msg);
                            $("#tbList").datagrid("load");
                        }
                    });
                }
                else {
                    com.message("information", "只有授权人才能终止授权");
                }
            }
            else {
                com.message("information", "请选中一行");
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="divTotal" style="height: 100%; width: 100%">

        <table id="tbList" title="我的授权信息 " style="width: 100%">
        </table>
        <div id="divAddAuthor">
            <form id="authForm">
                <div style="margin-top: 10px">
                    开始时间：
                <input class="easyui-datetimebox" name="StartTime" id="StartTime"
                    data-options="required:true,editable:false" style="width: 170px" />
                </div>
                <div style="margin-top: 10px">
                    结束时间：
                <input class="easyui-datetimebox" name="EndTime" id="EndTime"
                    data-options="required:true,editable:false" style="width: 170px" />
                </div>
                <div style="margin-top: 10px">
                    &nbsp; &nbsp; 授权给：
                 <input class="easyui-textbox" id="ToUserNM" name="ToUserNM" data-options="buttonIcon:'icon-user_edit',onClickButton:function(){  picPer.open($(this)); },required:true" style="width: 170px; cursor: pointer;" /><input type="hidden" name="ToUserId" id="ToUserId" />
                </div>
            </form>
        </div>
        <div id="divToolBar" class="dialog-bottom">
            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-accept'" onclick="Confirm()">确定</a>
            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="Cancel()">取消</a>
        </div>
    </div>


    <div id='pickPerDiv'>
        <div id="picPerHead" style="height: 28px; width: 450px;">
            &nbsp;&nbsp;选择部门：<input id="perCombo" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;姓名：
            <input id='textSearchPer' type='text' />
        </div>


        <table id='tbPicPer' style='height: 273px; width: 480px; overflow: scroll'></table>

        <div class="dialog-bottom">&nbsp;<a href='#' class='easyui-linkbutton' data-options="iconCls:'icon-ok'" onclick="picPer.Confirm()">确定</a>&nbsp;&nbsp;&nbsp;<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="picPer.Cancel()">取消</a></div>
    </div>
</asp:Content>
